from download import down
import pymongo
# client["47.75.39.50"] = pymongo.MongoClient("47.75.39.50",socketKeepAlive=True,maxPoolSize=200)
# cli = client["47.75.39.50"].admin.authenticate("admin321", "dsf::6666,,<<", mechanism='SCRAM-SHA-1')
# for x in cli.city.store:
#     down.delay(x[""])

import MySQLdb
import MySQLdb.cursors
import redis
pool = redis.ConnectionPool(host='localhost', port=6379)
redisconn = redis.Redis(connection_pool=pool)
mysqldb = MySQLdb.connect("47.75.39.50","xiaolei","ken402402", "shantianjunbak",charset="utf8",cursorclass=MySQLdb.cursors.DictCursor)
cursor = mysqldb.cursor()

# cursor.execute("select url from store where id not in ( select distinct(sid) from girl)")
cursor.execute("select url from store")
for y in cursor.fetchallDict():
    url = "https://www.cityheaven.net"+y["url"]
    print url
    redisconn.sadd("xcity:start_urls",url)